<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	template="/xhtml/bases/advertisementNewBase.xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:t="http://myfaces.apache.org/tomahawk"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:bargas="http://barganhas.com.br/barganhas">
	
	<!-- defining the scope of accountbase -->
	<ui:define name="accountHeader">
		<h:outputText value="#{msg.userAccountMyAdvertisements} #{msg.privateAreaFormSeparatorHeader} #{msg.privateAreaActionNew} ( #{msg.advertisementHeaderStepOne} ) "/>
	</ui:define>
	
	<!-- defining the scope of advertisementNewBase -->
	<ui:define name="advertisementFormBody">
		<h:panelGroup styleClass="boxUserAccountForm boxUserAccountFormInputs" layout="block">
			<h:panelGrid styleClass="tableInputFormUserAccount" columns="2" columnClasses="columnLabel, columnInput">
				<!-- advertisement type -->
				<h:outputLabel value="#{msg.advertisementAdvertisementType}:" for="advertisementType"/>
				<h:selectOneMenu id="advertisementType" value="#{advertisementBean.selectedAdvertisementType}"
					styleClass="inputMainForm bigInputuMainFormSelectMenu bigInputMainForm" converter="omnifaces.SelectItemsConverter">
					<f:selectItem itemLabel="#{msg.msgSelect}" itemValue=" " noSelectionOption="true"/>
					<f:selectItems value="#{advertisementBean.listAdvertisementType}" />
					
					<a4j:ajax event="change" execute="@this" render="panelAdvertisementTypeDetails" onbeforesubmit="popupLoading(true);" oncomplete="popupLoading(false);"/>
				</h:selectOneMenu>
				
				<!-- advertisement type's warning -->
				<h:column/>
				<h:panelGroup id="panelAdvertisementTypeDetails" layout="block">
					<h:panelGrid columns="1" rendered="#{advertisementBean.selectedAdvertisementType.id ne null}" styleClass="panelDetailsWarning">
						<h:outputText value="#{msg.advertisementAdvertisementTypeWarning}."/>
						<h:outputText value="#{msg.advertisementAdvertisementTypeTotalImg} #{advertisementBean.selectedAdvertisementType.totalPictures} #{msg.advertisementAdvertisementTypeTotalImgs}
												#{msg.advertisementAdvertisementTypeCost} #{msg.privateAreaCurrencySymbolReal} #{advertisementBean.selectedAdvertisementType.value}."/>
						<h:outputText value="#{msg.advertisementAdvertisementTypeDaysToExpire}  #{advertisementBean.selectedAdvertisementType.daysToExpire}
											 #{msg.advertisementAdvertisementTypeDaysToExpireDays}."/>
						<h:outputText value="#{advertisementBean.selectedAdvertisementType.description}"/>
					</h:panelGrid>
				</h:panelGroup>
				
				<!-- title -->
				<h:outputLabel value="#{msg.privateAreaTitle}:" for="title"/>
				<h:inputText id="title" value="#{advertisementBean.advertisement.title}" maxlength="400" styleClass="inputMainForm bigInputMainForm"/>
				
				<!-- description -->
				<h:outputLabel value="#{msg.privateAreaDescription}:" for="description"/>
				<h:inputTextarea id="description" value="#{advertisementBean.advertisement.description}"
					rows="3"
					styleClass="inputTextAreaMainForm bigInputMainForm">
				</h:inputTextarea>
				
				<!-- category -->
				<h:outputLabel value="#{msg.advertisementCategory}:" for="category"/>
				<h:selectOneMenu id="category" value="#{advertisementBean.selectedCategory}"
					styleClass="inputMainForm bigInputuMainFormSelectMenu bigInputMainForm" converter="omnifaces.SelectItemsConverter">
					<f:selectItem itemLabel="#{msg.msgSelect}" itemValue=" " noSelectionOption="true"/>
					<f:selectItems value="#{advertisementBean.listCategories}" />
				</h:selectOneMenu>
				
				<!-- contact phone number 1 -->
				<h:outputLabel value="#{msg.advertisementContactPhoneNumberOne}:" for="contactPhoneNumberOne"/>
				<h:inputText id="contactPhoneNumberOne" value="#{advertisementBean.advertisement.contactPhoneNumberOne}"
							maxlength="20" styleClass="inputMainForm mediumInputMainForm"/>

				<!-- contact phone number 2 -->
				<h:outputLabel value="#{msg.advertisementContactPhoneNumberTwo}:" for="contactPhoneNumberTwo"/>
				<h:inputText id="contactPhoneNumberTwo" value="#{advertisementBean.advertisement.contactPhoneNumberTwo}"
							maxlength="20" styleClass="inputMainForm mediumInputMainForm"/>

				<!-- contact email -->
				<h:outputLabel value="#{msg.advertisementContactMail}:" for="contactEmail"/>
				<h:inputText id="contactEmail" value="#{advertisementBean.advertisement.contactEmail}"
							maxlength="50" styleClass="inputMainForm mediumInputMainForm"/>
				
				<!-- value -->
				<h:outputLabel value="#{msg.privateAreaCurrencyValue} ( #{msg.privateAreaCurrencySymbolReal} ):" for="currencyValue" />
				<bargas:inputCurrencyConverted id="currencyValue" value="#{advertisementBean.advertisement.value}" maxlength="12" 
					styleClass="inputMainForm mediumInputMainForm" converterId="ConverterDoubleCurrencyReal"/>
				
				<!-- is product new -->
				<h:outputLabel value="#{msg.advertisementIsNewProduct} :" for="isProductNew"/>
				<h:selectOneRadio id="isProductNew" value="#{advertisementBean.isProductNew}" styleClass="inputMainForm">
					<f:selectItem itemLabel="#{msg.advertisementNewProduct}" itemValue="true"/>
					<f:selectItem itemLabel="#{msg.advertisementUseProduct}" itemValue="false"/>
				</h:selectOneRadio>
				
				<!-- list exchange by -->
				<h:outputLabel value="#{msg.advertisementListExchangeBy}:" for="listExchangeBy"/>
				<h:panelGrid columns="2" cellpadding="0" cellspacing="0">
					<h:inputTextarea id="listExchangeBy" value="#{advertisementBean.advertisement.exchangeBy}" rows="3" styleClass="inputTextAreaMainForm mediumInputMainForm">
					</h:inputTextarea>
					
					<h:graphicImage id="listExchangeByInfo" value="/images/help.png" style="margin-left: 10px;">
						<rich:tooltip target="listExchangeByInfo" attached="true" direction="auto" followMouse="true" showDelay="500" value="#{msg.advertisementExchangeByInfo}"/>
					</h:graphicImage>
				</h:panelGrid>
			</h:panelGrid>
		</h:panelGroup>
		
		<t:saveState value="#{advertisementBean.listAdvertisementType}"/>
		<t:saveState value="#{advertisementBean.listCategories}"/>
	</ui:define>
	
	<!-- defining the scope of accountbase -->
	<ui:define name="accountBottomButtons">
		<h:commandButton value="#{msg.msgGoNext}" styleClass="customButton2 buttonMainForm" action="#{advertisementBean.prepareNewStepTwo}" immediate="false" />
		<h:commandButton value="#{msg.privateAreaActionCancel}" styleClass="customButton2 buttonMainForm" action="#{advertisementBean.list}" immediate="true"/>
	</ui:define>
	
</ui:composition>
